package com.ouc.eddyAlgorithm.controller;


import com.ouc.common.annotation.Log;
import com.ouc.common.core.controller.BaseController;
import com.ouc.common.core.domain.AjaxResult;
import com.ouc.common.core.page.TableDataInfo;
import com.ouc.common.enums.BusinessType;
import com.ouc.common.utils.poi.ExcelUtil;
import com.ouc.eddyAlgorithm.domain.EddyGed;
import com.ouc.eddyAlgorithm.service.IEddyGedService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import java.util.List;
import org.springframework.web.bind.annotation.*;

/**
 * gedyolo计算涡旋临时表Controller
 *
 * @author b504
 * @date 2023-02-25
 */
@Controller
@CrossOrigin
@RequestMapping("/system/gedYolo")
public class EddyGedController extends BaseController {
  private String prefix = "system/gedYolo";

  @Autowired
  private IEddyGedService eddyGedService;

  @RequiresPermissions("system:gedYolo:view")
  @GetMapping()
  public String gedYolo() {
    return prefix + "/gedYolo";
  }

  /**
   * 查询gedyolo计算涡旋临时表列表
   */
  @RequiresPermissions("system:gedYolo:list")
  @PostMapping("/list")
  @ResponseBody
  public TableDataInfo list(EddyGed eddyGed) {
    startPage();
    List<EddyGed> list = eddyGedService.selectEddyGedList(eddyGed);
    return getDataTable(list);
  }

  /**
   * 导出gedyolo计算涡旋临时表列表
   */
  @RequiresPermissions("system:gedYolo:export")
  @Log(title = "gedyolo计算涡旋临时表", businessType = BusinessType.EXPORT)
  @PostMapping("/export")
  @ResponseBody
  public AjaxResult export(EddyGed eddyGed) {
    List<EddyGed> list = eddyGedService.selectEddyGedList(eddyGed);
    ExcelUtil<EddyGed> util = new ExcelUtil<EddyGed>(EddyGed.class);
    return util.exportExcel(list, "gedyolo计算涡旋临时表数据");
  }

  /**
   * 新增gedyolo计算涡旋临时表
   */
  @GetMapping("/add")
  public String add() {
    return prefix + "/add";
  }

  /**
   * 新增保存gedyolo计算涡旋临时表
   */
  @RequiresPermissions("system:gedYolo:add")
  @Log(title = "gedyolo计算涡旋临时表", businessType = BusinessType.INSERT)
  @PostMapping("/add")
  @ResponseBody
  public AjaxResult addSave(EddyGed eddyGed) {
    return toAjax(eddyGedService.insertEddyGed(eddyGed));
  }

  /**
   * 修改gedyolo计算涡旋临时表
   */
  @RequiresPermissions("system:gedYolo:edit")
  @GetMapping("/edit/{eddyId}")
  public String edit(@PathVariable("eddyId") Integer eddyId, ModelMap mmap) {
    EddyGed eddyGed = eddyGedService.selectEddyGedByEddyId(eddyId);
    mmap.put("eddyGed", eddyGed);
    return prefix + "/edit";
  }

  /**
   * 修改保存gedyolo计算涡旋临时表
   */
  @RequiresPermissions("system:gedYolo:edit")
  @Log(title = "gedyolo计算涡旋临时表", businessType = BusinessType.UPDATE)
  @PostMapping("/edit")
  @ResponseBody
  public AjaxResult editSave(EddyGed eddyGed) {
    return toAjax(eddyGedService.updateEddyGed(eddyGed));
  }

  /**
   * 删除gedyolo计算涡旋临时表
   */
  @RequiresPermissions("system:gedYolo:remove")
  @Log(title = "gedyolo计算涡旋临时表", businessType = BusinessType.DELETE)
  @PostMapping("/remove")
  @ResponseBody
  public AjaxResult remove(String ids) {
    return toAjax(eddyGedService.deleteEddyGedByEddyIds(ids));
  }

}
